package com.wyzy.book.controller;

import jakarta.servlet.http.HttpSession;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {
    @RequestMapping("/login")
    public boolean login(String userName,String password, HttpSession session){
        if(!StringUtils.hasLength(userName)
                ||!StringUtils.hasLength(password)){
            System.out.println("第一道检查");
            return false;
        }
        //TODO 暂且写死
        if("admin".equals(userName) && "admin".equals(password)){
            System.out.println("第二道检查");
            session.setAttribute("userName",userName);
            return true;
        }
        return false;
    }
}
